//
//  ICLocationModel.swift
//  ICCLLocationDemo
//
//  Created by cc on 2018/7/20.
//  Copyright © 2018年 cc. All rights reserved.
//

import UIKit
import CoreLocation
class ICLocationModel: NSObject {
    public var latitude: Double?
    public var longitude: Double?
    ///国家代码
    public var countryCode: String?
    public var country: String?
    public var province: String?
    ///其他行政信息 （可能是乡县镇）
    public var subArea: String?
    public var city: String?
    public var district: String?
    public var street: String?
    ///子街道
    public var subStreet: String?
    ///具体位置
    public var name: String?
    ///最详细地址
    public var formattedAddress: String?
    ///邮政编码
    public var postalCode: String?
    ///时区
    public var timeZone: TimeZone?
    ///区域
    public var region: CLRegion?
    ///水源、湖泊
    public var inlandWater: String?
    ///海洋
    public var ocean: String?
    ///关联的或利益相关的地标
    public var areasOflntertest: [String]?
    //位置字典
    public var addressDic: [AnyHashable: Any]?
    
    init(_ placemark: CLPlacemark) {
        super.init()
        latitude = placemark.location?.coordinate.latitude
        longitude = placemark.location?.coordinate.longitude
        countryCode = placemark.isoCountryCode
        country = placemark.country
        province = placemark.administrativeArea
        subArea = placemark.subAdministrativeArea
        city = placemark.locality
        district = placemark.subLocality
        street = placemark.thoroughfare
        subStreet = placemark.subThoroughfare
        name = placemark.name
        postalCode = placemark.postalCode
        addressDic = placemark.addressDictionary
        timeZone = placemark.timeZone
        region = placemark.region
        inlandWater = placemark.inlandWater
        ocean = placemark.ocean
        areasOflntertest = placemark.areasOfInterest
        if let dic = addressDic {
            formattedAddress = dic["FormattedAddressLines"] as? String
        }
        
    }
}
